//
// Created by dcang on 2021/7/12.
//

#ifndef NDKDEMO_YCVIDEO_H
#define NDKDEMO_YCVIDEO_H

#include "YcBasePlayer.h"
#include "YcQueue.h"
#include "YcJavaCall.h"
#include "AndroidLog.h"
#include "YcAudio.h"

extern "C"
{
#include <libavutil/time.h>
};

class YcVideo : public YcBasePlayer{
public:
    YcQueue *queue = NULL;
    YcAudio *ycAudio = NULL;
    YcPlayStatus *ycPlayStatus = NULL;
    pthread_t videoThread;
    pthread_t decFrame;
    YcJavaCall *ycjavaCall = NULL;

    double delayTime = 0;
    int rate = 0;
    bool isExit = true;
    bool isExit2 = true;
    int codecType = -1;
    double video_clock = 0;
    double framePts = 0;
    bool frameratebig = false;
    int playcount = -1;

public:
    YcVideo(YcJavaCall *javaCall, YcAudio *audio, YcPlayStatus *playStatus);
    ~YcVideo();

    void playVideo(int codecType);
    void decodVideo();
    void release();
    double synchronize(AVFrame *srcFrame, double pts);

    double getDelayTime(double diff);

    void setClock(int secds);
};


#endif //NDKDEMO_YCVIDEO_H
